import React, { Fragment } from "react";
import { NavLink, Route } from "react-router-dom"
//核心思想就是二次封装NavLink
//这个组件接收to属性
//组合接收文字
//❥
class CustomLink extends React.Component {
    render() {
        //to是从组件传递下来的路径
        let { to, children } = this.props
        return (
            <Route path={to} children={
                (props) => {
                    // console.log(props.match);
                    return (
                        <Fragment>
                            {props.match?"❥":""}
                            <NavLink to={to}>{children}</NavLink>
                            <br />
                        </Fragment>
                    )
                }
            } />
        )
    }
}

export default CustomLink